package com.duck.duckchatbackend.controller;

import com.duck.duckchatbackend.annotation.GlobalInterceptor;
import com.duck.duckchatbackend.entity.po.UserInfoBeauty;
import com.duck.duckchatbackend.entity.query.UserInfoBeautyQuery;
import com.duck.duckchatbackend.entity.vo.PaginationResultVO;
import com.duck.duckchatbackend.entity.vo.ResponseVO;
import com.duck.duckchatbackend.service.UserInfoBeautyService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.constraints.NotNull;

@RestController("adminUserInfoBeautyController")
@RequestMapping("/admin")
public class AdminUserInfoBeautyController extends ABaseController{
    @Resource
    private UserInfoBeautyService userInfoBeautyService;
    @RequestMapping("/loadBeautyAccountList")
    @GlobalInterceptor(checkAdmin = true)
    public ResponseVO loadBeautyAccountList(UserInfoBeautyQuery query){
        query.setOrderBy("id desc");
        PaginationResultVO resultVO = userInfoBeautyService.findListByPage(query);
        return  getSuccessResponseVO(resultVO);
    }
    @RequestMapping("/saveBeautAccount")
    @GlobalInterceptor(checkAdmin = true)
    public ResponseVO saveBeautyAccount(UserInfoBeauty beauty){
        userInfoBeautyService.saveAccount(beauty);
        return  getSuccessResponseVO(null);
    }

    @RequestMapping("/deleteBeautyAccount")
    @GlobalInterceptor(checkAdmin = true)
    public ResponseVO deleteBeautyAccount(@NotNull Integer id){
        userInfoBeautyService.deleteUserInfoBeautyById(id);
        return  getSuccessResponseVO(null);
    }
}
